 /*
 * KIMWONSORK@GMAIL.COM
 * COPYRIGHT CRAYONSOFT All rights reserved.
 * 2013오후 10:02:05
 * kws
 */

package com.crayon.util;

import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Currency;

public class UTILCurrency {


	public static String formatCurrencyPrice(long value){
		// Get a currency formatter for the current locale.
		NumberFormat fmt = NumberFormat.getCurrencyInstance();
		Currency currency = Currency.getInstance("KRW");
		fmt.setCurrency(currency);
		fmt.setMinimumFractionDigits(0);
		
		return fmt.format(value);
	}
	
	public static String formatWonPrice(long value){
		DecimalFormat fmt = new DecimalFormat("#,###,###,###,###");
		//fmt.setMinimumFractionDigits(0);
		
		return fmt.format(value);
	}
	
	public static String formatPrice(long value){
		DecimalFormat fmt = new DecimalFormat("#,###,###,###,###");
		//fmt.setMinimumFractionDigits(0);
		return fmt.format(value);
	}
	
	public static String formatZeroPrice(long value){
		DecimalFormat df = new DecimalFormat("#,###,###,###,##0");
		return df.format(value);
	}
	
	
	public static String onlyNum(String str){
		if(str==null) return "0";
		StringBuffer sb = new StringBuffer();
		for(int i = 0; i < str.length(); i++){
			if( Character.isDigit( str.charAt(i) ) ) {
				sb.append( str.charAt(i) );
			}else if(str.charAt(i)=='-'){
				sb.append(str.charAt(i));
			}
		}
		return sb.toString();
	}

}
